A shader class, feeding data to a Program. More...
Public Member Functions | |
| Shader () | |
| virtual | ~Shader () |
| unsigned int | getId () const |
| bool | isUsableScene () const |
| bool | isUsablePostProcess () const |
| bool | isUsableCompute () const |
| bool | isUsableGeometry () const |
| bool | isUsableRaytracing () const |
| Program * | getAttachedShaderProgram () const |
| unsigned int | getMaxInstancePerBuffer () const |
| bool | getDirtyInstanceData () const |
| virtual void | setAttachedShaderProgram (Program *prog) |
| void | setId (unsigned int id) |
| virtual void | setMaxInstancePerBuffer (unsigned int value) |
| void | setDirtyInstanceData (bool value) |
| virtual bool | load () override |
| virtual void | unload () override |
| ConstantBuffer * | addConstantBuffer (unsigned int registerSlot, unsigned int space=0) |
| ConstantBuffer * | getConstantBuffer (unsigned int slot, unsigned int space=0) const |
| void | changeConstantBufferSlot (unsigned int fromSlot, unsigned int toSlot, unsigned int space=0) |
| void | changeConstantBufferSpace (unsigned int fromSpace, unsigned int toSpace, unsigned int slot) |
| void | deleteConstantBuffer (unsigned int slot, unsigned int space=0) |
| const ConstantBufferResourceDesc * | getConstantBufferPerIndex (unsigned int index) const |
| void | addTexture (ShaderResource *texOrUav, unsigned int registerSlot, unsigned int space=0) |
| ShaderResource * | getTexture (unsigned int slot, unsigned int space=0) const |
| void | setTexture (ShaderResource *texOrUav, unsigned int slot, unsigned int space=0) |
| void | changeTextureSlot (unsigned int fromSlot, unsigned int toSlot, unsigned int space=0) |
| void | changeTextureSpace (unsigned int fromSpace, unsigned int toSpace, unsigned int slot) |
| void | forgetTexture (unsigned int slot, unsigned int space=0) |
| const ShaderResourceDesc * | getTexturePerIndex (unsigned int index) const |
| void | addSampler (Sampler *sampler, unsigned int registerSlot, unsigned int space=0) |
| Sampler * | getSampler (unsigned int slot, unsigned int space=0) const |
| void | setSampler (Sampler *sampler, unsigned int slot, unsigned int space=0) |
| void | changeSamplerSlot (unsigned int fromSlot, unsigned int toSlot, unsigned int space=0) |
| void | changeSamplerSpace (unsigned int fromSpace, unsigned int toSpace, unsigned int slot=0) |
| void | forgetSampler (unsigned int slot, unsigned int space=0) |
| const SamplerResourceDesc * | getSamplerPerIndex (unsigned int index) const |
| void | addUavBuffer (Buffer *buffer, unsigned int registerSlot, unsigned int space=0) |
| Buffer * | getUavBuffer (unsigned int slot, unsigned int space=0) const |
| void | setUavBuffer (Buffer *buffer, unsigned int slot, unsigned int space=0) |
| void | changeUavBufferSlot (unsigned int fromSlot, unsigned int toSlot, unsigned int space=0) |
| void | changeUavBufferSpace (unsigned int fromSpace, unsigned int toSpace, unsigned int slot=0) |
| void | forgetUavBuffer (unsigned int slot, unsigned int space=0) |
| const UavResourceDesc * | getUavBufferPerIndex (unsigned int index) const |
| virtual ShaderInstanceMemorySlot * | addInstanceMemorySlot () |
| virtual ShaderInstanceMemorySlot * | getInstanceMemorySlot (unsigned int index) |
| virtual ShaderInstanceMemorySlot * | getInstanceMemorySlotReadOnly (unsigned int index) const |
| virtual void | changeInstanceMemorySlotOrder (unsigned int fromIndex, unsigned int toIndex) |
| virtual void | deleteInstanceMemorySlot (unsigned int index) |
| virtual void | exportClassToTree (nkExport::Node *rootNode) override |
| virtual void | importClassFromTree (nkExport::Node *rootNode) override |
Public Member Functions inherited from nkGraphics::Resource | |
| Resource () | |
| Resource (const char *path) | |
| virtual | ~Resource () |
| bool | isReadyForRendering () const |
| bool | isUnloaded () const |
| RESOURCE_LOAD_STATE | getLoadState () const |
| std::string_view | getResourcePath () const |
| RESOURCE_TYPE | getResourceTypeName () const |
| std::string_view | getResourceName () const |
| bool | getHidden () const |
| virtual void | setResourcePath (const std::string_view &path) |
| void | setResourceName (const std::string_view &name) |
| void | setHidden (bool value) |
Public Member Functions inherited from nkExport::Exportable | |
| Exportable () | |
| virtual | ~Exportable () |
A shader class, feeding data to a Program.
The Shader class is describing all the resources to bind to a Program during rendering.
| nkGraphics::Shader::Shader | ( | ) |
Constructor. See ShaderManager::createOrRetrieveShader().
|
virtual |
Destructor.
| unsigned int nkGraphics::Shader::getId | ( | ) | const |
| bool nkGraphics::Shader::isUsableScene | ( | ) | const |
| bool nkGraphics::Shader::isUsablePostProcess | ( | ) | const |
| bool nkGraphics::Shader::isUsableCompute | ( | ) | const |
| bool nkGraphics::Shader::isUsableGeometry | ( | ) | const |
| bool nkGraphics::Shader::isUsableRaytracing | ( | ) | const |
| Program* nkGraphics::Shader::getAttachedShaderProgram | ( | ) | const |
| unsigned int nkGraphics::Shader::getMaxInstancePerBuffer | ( | ) | const |
| bool nkGraphics::Shader::getDirtyInstanceData | ( | ) | const |
|
virtual |
| prog | The program to attach to the shader. |
| void nkGraphics::Shader::setId | ( | unsigned int | id | ) |
| id | The id to attach to the shader. Should not be called by external code. |
|
virtual |
| value | The maximum instance count allowed per instance buffer. |
| void nkGraphics::Shader::setDirtyInstanceData | ( | bool | value | ) |
| value | Whether the instance data should be flagged as dirty or not. |
|
overridevirtual |
Initializes the shader and make it ready for rendering.
Implements nkGraphics::Resource.
|
overridevirtual |
Unloads and frees all internal memory of the shader.
Implements nkGraphics::Resource.
| ConstantBuffer* nkGraphics::Shader::addConstantBuffer | ( | unsigned int | registerSlot, |
| unsigned int | space = 0 |
||
| ) |
Adds a constant buffer to the data fed to the program.
| registerSlot | The register slot the resource is attached to. |
| space | The register space the resource is attached to. |
| ConstantBuffer* nkGraphics::Shader::getConstantBuffer | ( | unsigned int | slot, |
| unsigned int | space = 0 |
||
| ) | const |
| slot | The register slot the requested resource covers. |
| space | The register space the requested resource covers. |
| void nkGraphics::Shader::changeConstantBufferSlot | ( | unsigned int | fromSlot, |
| unsigned int | toSlot, | ||
| unsigned int | space = 0 |
||
| ) |
Changes the slot a resource should be fed to.
| fromSlot | The slot the resource currently feeds. |
| toSlot | The slot to feed. |
| space | The register space the resource currently occupies. |
| void nkGraphics::Shader::changeConstantBufferSpace | ( | unsigned int | fromSpace, |
| unsigned int | toSpace, | ||
| unsigned int | slot | ||
| ) |
Changes the space a resource should be fed to.
| fromSpace | The register space the resource currently feeds. |
| toSpace | The space to feed. |
| slot | The register slot the resource currently occupies. |
| void nkGraphics::Shader::deleteConstantBuffer | ( | unsigned int | slot, |
| unsigned int | space = 0 |
||
| ) |
Removes a constant buffer from the feeding, and frees its memory.
| slot | The register slot used by the resource. |
| space | The register space used by the resource. |
| const ConstantBufferResourceDesc* nkGraphics::Shader::getConstantBufferPerIndex | ( | unsigned int | index | ) | const |
Accesses a resource, by index. Note that an index can return different resources as the internal memory is changed. Mainly useful to loop over all the resources in one go.
| index | The index of the resource wanted. |
| void nkGraphics::Shader::addTexture | ( | ShaderResource * | texOrUav, |
| unsigned int | registerSlot, | ||
| unsigned int | space = 0 |
||
| ) |
Adds a texture or buffer to the data fed to the program.
| texOrUav | The resource to feed to the program. |
| registerSlot | The register slot the resource is attached to. |
| space | The register space the resource is attached to. |
| ShaderResource* nkGraphics::Shader::getTexture | ( | unsigned int | slot, |
| unsigned int | space = 0 |
||
| ) | const |
| slot | The register slot the requested resource covers. |
| space | The register space the requested resource covers. |
| void nkGraphics::Shader::setTexture | ( | ShaderResource * | texOrUav, |
| unsigned int | slot, | ||
| unsigned int | space = 0 |
||
| ) |
Changes the resource fed to a slot and space.
| texOrUav | The resource to feed. |
| slot | The currently used register slot. |
| space | The currently used space. |
| void nkGraphics::Shader::changeTextureSlot | ( | unsigned int | fromSlot, |
| unsigned int | toSlot, | ||
| unsigned int | space = 0 |
||
| ) |
Changes the slot a resource should be fed to.
| fromSlot | The slot the resource currently feeds. |
| toSlot | The slot to feed. |
| space | The register space the resource currently occupies. |
| void nkGraphics::Shader::changeTextureSpace | ( | unsigned int | fromSpace, |
| unsigned int | toSpace, | ||
| unsigned int | slot | ||
| ) |
Changes the space a resource should be fed to.
| fromSpace | The register space the resource currently feeds. |
| toSpace | The space to feed. |
| slot | The register slot the resource currently occupies. |
| void nkGraphics::Shader::forgetTexture | ( | unsigned int | slot, |
| unsigned int | space = 0 |
||
| ) |
Removes a resource from the feeding.
| slot | The register slot used by the resource. |
| space | The register space used by the resource. |
| const ShaderResourceDesc* nkGraphics::Shader::getTexturePerIndex | ( | unsigned int | index | ) | const |
Accesses a resource, by index. Note that an index can return different resources as the internal memory is changed. Mainly useful to loop over all the resources in one go.
| index | The index of the resource wanted. |
| void nkGraphics::Shader::addSampler | ( | Sampler * | sampler, |
| unsigned int | registerSlot, | ||
| unsigned int | space = 0 |
||
| ) |
Adds a sampler to the data fed to the program.
| sampler | The resource to feed to the program. |
| registerSlot | The register slot the resource is attached to. |
| space | The register space the resource is attached to. |
| Sampler* nkGraphics::Shader::getSampler | ( | unsigned int | slot, |
| unsigned int | space = 0 |
||
| ) | const |
| slot | The register slot the requested resource covers. |
| space | The register space the requested resource covers. |
| void nkGraphics::Shader::setSampler | ( | Sampler * | sampler, |
| unsigned int | slot, | ||
| unsigned int | space = 0 |
||
| ) |
Changes the resource fed to a slot and space.
| sampler | The resource to feed. |
| slot | The currently used register slot. |
| space | The currently used space. |
| void nkGraphics::Shader::changeSamplerSlot | ( | unsigned int | fromSlot, |
| unsigned int | toSlot, | ||
| unsigned int | space = 0 |
||
| ) |
Changes the slot a resource should be fed to.
| fromSlot | The slot the resource currently feeds. |
| toSlot | The slot to feed. |
| space | The register space the resource currently occupies. |
| void nkGraphics::Shader::changeSamplerSpace | ( | unsigned int | fromSpace, |
| unsigned int | toSpace, | ||
| unsigned int | slot = 0 |
||
| ) |
Changes the space a resource should be fed to.
| fromSpace | The register space the resource currently feeds. |
| toSpace | The space to feed. |
| slot | The register slot the resource currently occupies. |
| void nkGraphics::Shader::forgetSampler | ( | unsigned int | slot, |
| unsigned int | space = 0 |
||
| ) |
Removes a resource from the feeding.
| slot | The register slot used by the resource. |
| space | The register space used by the resource. |
| const SamplerResourceDesc* nkGraphics::Shader::getSamplerPerIndex | ( | unsigned int | index | ) | const |
Accesses a resource, by index. Note that an index can return different resources as the internal memory is changed. Mainly useful to loop over all the resources in one go.
| index | The index of the resource wanted. |
| void nkGraphics::Shader::addUavBuffer | ( | Buffer * | buffer, |
| unsigned int | registerSlot, | ||
| unsigned int | space = 0 |
||
| ) |
Adds a uav buffer to the data fed to the program.
| buffer | The resource to feed to the program. |
| registerSlot | The register slot the resource is attached to. |
| space | The register space the resource is attached to. |
| Buffer* nkGraphics::Shader::getUavBuffer | ( | unsigned int | slot, |
| unsigned int | space = 0 |
||
| ) | const |
| slot | The register slot the requested resource covers. |
| space | The register space the requested resource covers. |
| void nkGraphics::Shader::setUavBuffer | ( | Buffer * | buffer, |
| unsigned int | slot, | ||
| unsigned int | space = 0 |
||
| ) |
Changes the resource fed to a slot and space.
| buffer | The resource to feed. |
| slot | The currently used register slot. |
| space | The currently used space. |
| void nkGraphics::Shader::changeUavBufferSlot | ( | unsigned int | fromSlot, |
| unsigned int | toSlot, | ||
| unsigned int | space = 0 |
||
| ) |
Changes the slot a resource should be fed to.
| fromSlot | The slot the resource currently feeds. |
| toSlot | The slot to feed. |
| space | The register space the resource currently occupies. |
| void nkGraphics::Shader::changeUavBufferSpace | ( | unsigned int | fromSpace, |
| unsigned int | toSpace, | ||
| unsigned int | slot = 0 |
||
| ) |
Changes the space a resource should be fed to.
| fromSpace | The register space the resource currently feeds. |
| toSpace | The space to feed. |
| slot | The register slot the resource currently occupies. |
| void nkGraphics::Shader::forgetUavBuffer | ( | unsigned int | slot, |
| unsigned int | space = 0 |
||
| ) |
Removes a resource from the feeding.
| slot | The register slot used by the resource. |
| space | The register space used by the resource. |
| const UavResourceDesc* nkGraphics::Shader::getUavBufferPerIndex | ( | unsigned int | index | ) | const |
Accesses a resource, by index. Note that an index can return different resources as the internal memory is changed. Mainly useful to loop over all the resources in one go.
| index | The index of the resource wanted. |
|
virtual |
Adds an instance memory slot to the data feeding. Instance memory slots are fed sequentially, in the order they are declared. Be sure to align all structures.
|
virtual |
Retrieves an existing instance memory slot.
| index | The index of the slot to retrieve. |
|
virtual |
Retrieves an existing instance memory slot, for read only operation. Use this function whenever possible as this won't dirtify the instance tracking data.
| index | The index of the slot to retrieve. |
|
virtual |
Changes the ordering within the slots.
| fromIndex | The slot to move. |
| toIndex | The index to move the slot to. |
|
virtual |
Erases and frees an instance memory slot.
| index | The index of the slot to erase. |
|
overridevirtual |
Basic exporting capabilities.
| rootNode | The tree to export to. |
Implements nkExport::Exportable.
|
overridevirtual |
Basic importing capabilities.
| rootNode | The tree to import to. |
Implements nkExport::Exportable.